<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>展示ajax请求京东某个商品展示价格</title>
		<script src="js/jquery.min.js"></script>
	</head>
	<body>
		<div id="rtnData"></div>
		<div id="itemPrice"></div>
		<div id="itemId"></div>
	</body>
	<script>
		$().ready(function(){
			//1、发起ajax请求
			//https://p.3.cn/prices/mgets?skuIds=J_100007851351
			$.ajax({
				type: "POST",
				url: "https://p.3.cn/prices/mgets",	
				contentType: "application/json;charset=utf8;",
				data: {
					"skuIds": "J_100007851351"
				},
				dataType: "jsonp",
				success: function(data){
					//2、解析json字符串，展现页面
					//把data js对象转成json字符串
					$("#rtnData").text( "返回结果："+JSON.stringify(data) );
					$("#itemPrice").html("商品价格：<font color=\"red\">" + data[0].p +"</font>" );
					$("#itemId").text("商品编号："+ data[0].id.substring(2) );
				},
				error: function(){
					alert('请求失败，请联系管理员!');
				}
			})
			
		})
	</script>
</html>
